home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS3.ZIP / DOSSBDRS.TXT < prev    next >
Text File  |  1985-11-24  |  22KB  |  383 lines

  1.                     The PATH to Your Command
  2.         (PC Magazine Vol 3 No 6 Apr 3, 1984/Peter Norton)
  3.  
  4.      When we give DOS a command, such as FORMAT or CHKDSK, it has to
  5. find the program that will carry out that command.  Several of the most
  6. fundamental commands, such as DIR and DATE, are built into COMMAND.COM.
  7. These are called the internal commands.  If the command that we've
  8. asked DOS to perform is internal, DOS's command interpreter has the
  9. program that's needed right at hand, so it looks no further.
  10.      If DOS doesn't find a command in its internal table, then it looks
  11. on disk for a command file (a file with an extension of COM, EXE or
  12. BAT) with the same name as the command we entered.  Here is where DOS
  13. 2.x is different from DOS 1.x.  DOS 2.x allows us to use the PATH
  14. command to look in several different places for a command file.  The
  15. PATH command lets us instruct DOS to hunt for our command files in as
  16. many places on disk as we want.  Without a PATH command, DOS looks for
  17. a command where it has always looked, in the current directory of the
  18. current drive.
  19.      Suppose we have a PC with a drive C configured.  We might keep
  20. many programs, particularly DOS programs like CHKDSK, all in one
  21. directory.  Let's say the programs are kept in a directory named PROGS;
  22. the full path name to PROGS would be C:\PROGS.
  23.      Ordinarily, if we are working in another directory, we wouldn't be
  24. able to get to our programs.  But if we entered a PATH command, we can
  25. tell DOS to look to our PROGS directory: 
  26.           PATH C:\PROGS
  27. Once the PATH command is entered, DOS will keep track of it and look to
  28. the directory we've specified for command files.  If we've switched our
  29. current directory somewhere else, DOS will still be able to find and
  30. execute any programs in the PROGS directory.
  31.      This operation works even if we've switched the current drive.
  32. Say we wanted to work with a diskette for a moment, and we've switched
  33. out current drive to the A: drive.  With the PATH command show above,
  34. DOS will still be able to find and use all the programs in our PROGS
  35. directory.
  36.      To make sure that the PATH command works right, it's important to
  37. specify carefully the full pathname of the directory including its
  38. drive letter.  Suppose we'd left this part off in the previous example,
  39. so that the PATH was just \PROGS.  When we switched our current drive
  40. to A or any other drive, DOS would search for a PROGS directory on that
  41. drive, since the PATH command didn't specify which drive to look at.
  42.      There's even more power to the PATH command.  We aren't limited to
  43. telling DOS to search a single directory path -- we can give lots of
  44. paths in the PATH command.  To do this, we just list all the directory
  45. paths we want DOS to search separated by semicolons, for example, two
  46. directories:
  47.           PATH C:\PROGS;C:\OTHERS
  48. After we enter that command, DOS will go looking for commands in both
  49. directories in the order we gave them.  In this example, DOS will
  50. search the PROGS file before it searches OTHERS.  As soon as it finds
  51. the command program we've asked for, it will run it.
  52.      We can put lots of paths in the search if we want to.  Although I
  53. don't think that it's a good idea to scatter programs through a bunch
  54. of directories, if your programs are scattered you can still use them
  55. all conveniently by setting up a PATH command that tells DOS to look
  56. through all of them.
  57.      Another use of multiple paths is that the paths we tell DOS to
  58. search can be on different drives.  This turns out to be one of the
  59. best and handiest uses of the PATH command.
  60.      While we might not have our programs spread out in several 
  61. subdirectories, we might have them in several different drives.  There
  62. are lots of good reasons for doing this.  For example, if you use a
  63. RAMdisk, you could load your most frequently used programs into the
  64. RAMdisk and use the PATH command to have DOS try to find programs there
  65. first.  If your RAMdrive is drive C and you usually use a disk in
  66. drive A for any programs that aren't loaded into the RAMdrive, the PATH
  67. command you'd use is:
  68.           PATH C:\;A:\
  69. With that PATH, DOS will check the RAMdrive first, and then the A:
  70. drive.
  71.      Before DOS searches through any directories that we've asked it to
  72. search with the PATH command, it searches through the current directory
  73. in the current drive. This has two practical results.  First, there's
  74. no need to put our current directory into the search path.  DOS will
  75. look at the current directory anyway; putting it into the path will
  76. just make DOS search there twice and slow things down.  Second, since
  77. the current directory is searched first, we can't use the PATH command
  78. to override any programs in the current directory.  If you have a
  79. program in the current directory, but you want to use another version
  80. of it in another directory you'll have to give it another name, because 
  81. DOS will use the copy of the program in the current directory before it
  82. looks elsewhere.
  83.      Article continued in:
  84.  
  85.                   Keeping Subdirectories Simple
  86.        (PC Magazine Vol 3 No 7, Apr 17, 1984/Peter Norton)
  87.  
  88.      Subdirectories are best used by people who use hard disk systems.
  89. The extra work DOS goes through to use subdirectories on floppies makes
  90. the process painfully slow.  Subdirectories are for dividing files into
  91. groups, and nothing else.
  92.      Should you put subdirectories under subdirectories?  Only if you
  93. like to suffer.  The concept of using a complex tree structure is
  94. appealing.  We logically group our files in master subdirectories and
  95. subsidiary sub-subdirectories.  We build a tree structure to match the
  96. logical relationship of our files.  There are two main problems with
  97. using a complex tree-structure directory.  There's a performance
  98. problem: DOS has to do a lot more work to thread its way through all
  99. that foliage.  There's also a human problem.  It's a lot harder to keep
  100. track of directories for subdirectories under subdirectories.  Although
  101. the TREE command is there to help, it's of little practical assistance.
  102. Put all your subdirectories under your disk's root directory, not under
  103. one another.  Giving them distinct names is another thing.  A distinct
  104. signature for subdirectory names, such as .DIR or .SUB, is recommended.
  105. If all your subdirectories have the same distinct filename extension,
  106. then you can easily call up a list of all of them with the command:
  107.           DIR\*.SUB
  108.      If you'd like to have them sorted alphabetically, use a pipeline
  109. command like this:
  110.           DIR\*.SUB | SORT | MORE
  111.      I have devised a system to easily call up the subdirectory list.
  112. I put the pipeline command shown above into a batch command file named
  113. DD.BAT.  That way, by entering DD (Display Directories, as I call it),
  114. I get a sorted list of my subdirectories.  At the moment I have 26
  115. subdirectories, and this batch command helps me keep all of them
  116. straight.
  117.      The real question is how to group files in subdirectories and then
  118. how to work with them.  The first rule is to subdivide as little as
  119. possible.  Put everything that you don't really need to separate out
  120. into one catchall directory, such as your disk's root directory.  This
  121. would include all the standard DOS programs and any miscellaneous
  122. programs that you don't need to keep track of separately.  My root
  123. directory, for example, has 145 files in it; almost every program I
  124. have is in there.  I don't need to look at them; I just want them
  125. working for me.  So I stick them all into my root directory and forget
  126. about them.  Remember that the PATH command keeps the programs in your
  127. catchall directory on tap at all times.  My catchall directory is the
  128. root directory of drive C.  I keep the PATH command set to C:\, which
  129. provides me with immediate access to every program I have stored there,
  130. no matter what drive or subdirectory I'm using.  
  131.      Your catchall directory is dedicated to holding everything you
  132. never want to see.  It should be filled with programs that you use but
  133. that you wouldn't need a list of.  The catchall directory is a
  134. convenient place to dump things that you don't need to keep track of;
  135. subdirectories are what you use for things that you do need to keep
  136. track of.
  137.      The next rule is some programs deserve their own distinct 
  138. subdirectories.  When they do, separate them from your catchall
  139. directory.  When you expect to have more than one version of a program,
  140. for example, and you want to keep both the old and new versions, use a
  141. subdirectory.  Or when a series of programs works together and you want
  142. to be able to see a list of them to remind you of their names, having a
  143. tight little subdirectory of all the programs in one working system
  144. makes it easier to use them.  For example, I keep my accounting system
  145. in a subdirectory and I can quickly remind myself of all the program
  146. names with the command:
  147.           DIR\GL\*.BAS
  148. (BAS, because the programs are written in BASIC.)
  149.      Whenever you have programs separated out into subdirectories use
  150. the PATH command to make sure that they are on tap at all times.
  151. Suppose that your catchall is the root directory of your hard disk,
  152. drive C, and you've got two program subdirectories, NORTON and C-TOOLS.
  153. In addition, you load some programs into a RAM drive (drive D) for
  154. faster access.  Here's your ideal PATH command:
  155.           PATH D:\;C:\;C:\NORTON;C:\C-TOOLS
  156.      There is one more situation in which it makes sense to separate
  157. out programs into their own subdirectories -- when the programs use
  158. their own data files in addition to the files that we want them to work
  159. on.  Examples of programs like this are spelling checkers, which use
  160. dictionary files, and sophisticated programs like Lotus 1-2-3 that
  161. reads program overlay files and also uses initialization or profile
  162. files.  Programs like these create a special situation that complicates
  163. our work.
  164.  
  165. -----------------------------------------------------------------
  166.                     The Stubborn Subdirectory
  167.               (PC World April 1985 The Help Screen)
  168.  
  169.      To delete (remove) a subdirectory, the directory must not contain
  170. any files or other subdirectories, and the current directory must not
  171. be the one destined for deletion.  Begin by making the subdirectory to
  172. delete the current directory [CD\directory-name].  Next do an ERASE *.*
  173. to delete all the file entries that this directory contains.  Follow
  174. this by taking a directory listing [DIR] to check that this directory
  175. does not include any subdirectory entires.  The only entries left in
  176. this case are the period, which indicates that this is a subdirectory,
  177. and the double period, which DOS uses to locate the directory's parent
  178. (the higher-level directory that encompasses this directory).  Then
  179. change the current directory to the root directory [CD\] and execute
  180. RD\directoryname.  Problem:  You receive the standard error message,
  181. "Invalid path, not directory, or directory not empty."  What prevents
  182. removal of this subdirectory?
  183.      The steps are essentially correct.  But let's review the possible
  184. errors in the DOS message:
  185.      Directory not empty.  Although the DOS manual notes that ERASE*.*
  186. deletes all files in the current directory (and that ERASE [drive:]path
  187. deletes all the files in the path-specified directory), ERASE does not
  188. delete hidden or system files.  Hidden and system files are excluded
  189. from directory listings and from the "number of files" report in a
  190. listing's last line.  Hidden and system files within a subdirectory are
  191. difficult to delete without a special utility that can list such files
  192. and change their attributes, converting them into "normal" (ERASEable)
  193. files.
  194.      Not directory.  In most cases, this error message refers to a
  195. misspelled directory name.  It's also possible that a directory name
  196. may have been altered to include a nondisplayable character, but that
  197. is rare.
  198.      Invalid path.  To locate a specific subdirectory, a DOS command
  199. must be supplied with a path parameter that includes, in the correct
  200. order, every subdirectory level, from either the root directory down
  201. to the desired directory; the current directory down to the desired
  202. directory; or the current directory up to a common ancestor and then
  203. down to the desired subdirectory.
  204.      If DIR-22 is the current directory and you want to remove DIR-212,
  205. you could begin the path parameter with the root dir:
  206.           C>CD <Enter>
  207.           C:\DIR-22
  208.           C>RD\DIR-21\DIR-212 <Enter>
  209.      Alternatively, you could use the double period to ascend the path
  210. from the current directory to a common directory, then specify the path
  211. down from that directory:
  212.           C>CD <Enter>
  213.           C:\DIR-2
  214.           C>RD DIR-21\DIR-212 <Enter>
  215.      Instead of DIR-22, suppose the current directory is DIR-2.  In
  216. that case, to remove DIR-212, a descendant of the current directory,
  217. you may begin the path parameter with the appropriate child of the
  218. current directory:
  219.           C>CD <Enter>
  220.           C:\DIR-22
  221.           C>RD..\DIR-21\DIR-212 <Enter>
  222.      Note that in each example the path parameter includes every 
  223. subdirectory name along the specified path.  Even if the root directory
  224. were the current directory (instead of DIR-22) in the first example,
  225. the path parameter zDIR-212 would be invalid because the intermediate
  226. subdirectories have been omitted.
  227.      It may be that the stubborn directory is not a child of the root
  228. directory, in which case the command RD\directoryname omits the
  229. intermediate subdirectory or subdirectories.
  230.  
  231. -----------------------------------------------------------------
  232.                           Subdirectory Magic
  233.           (PC Magazine Vol 4 No 10 May 14, 1985 User-to-User)
  234.  
  235.      DOS allows users to organize their files by pigeon-holing 
  236. everything away in nested subdirectories.  But DOS doesn't provide a 
  237. convenient way to rename directories.  To rename a directory, most
  238. users create a new one with the new name, copy all the files into it
  239. from the old one, and remove the old one -- or they take advantage of
  240. special utilities like those published in PC Magazine's Programming
  241. Column.  Advanced users can zip into the disk directory with DEBUG and
  242. revise any filename.
  243.      However, DOS 3.0 users can change any subdirectory name simply by 
  244. going into BASIC 3.0 and using its NAME command.  For instance, to 
  245. change the name of the DOS subdirectory \SALT into \PEPPER, all a BASIC 
  246. 3.0 user need type is:
  247.           NAME "\SALT" AS "\PEPPER"
  248. Note that this works only in BASIC 3.x.  A subdirectory name is handled 
  249. very much like other filenames, except that byte 11 of its directory 
  250. lising is a hex 10.  Incidentally, by using DEBUG, you can hide the 
  251. subdirectory listing by changing this byte from a &H10 to a &H12.
  252.  
  253. -----------------------------------------------------------------
  254.              Redirecting Files and Renaming Subdirectories
  255.            (PC Magazine Vol 4 No 12 June 11, 1985 PC Tutor)
  256.  
  257.      You can re-direct a file from one subdirectory into another
  258. without copying and erasing by using BASIC's NAME ...AS ... command
  259. in director (nonprogramming mode).  Enter:
  260.           NAME"\dir1\file.ext"
  261.           AS"\dir2\file.ext"
  262. The RENAME command in DOS won't work because it will not accept a 
  263. second path.  Is there a patch (using DEBUG) to RENAME.COM that will 
  264. enable DOS to do this, too?
  265.      Editor's Note:  This procedure does exactly as described using
  266. both DOS 2.1 and 3.0, plus adding the flexibility of changing the
  267. filename at the same time.  Not only can you move files, but if you
  268. have DOS 3.0 you can even use the same procedure to rename directories,
  269. something you can't do within DOS at all. For example, if you have a
  270. first-level subdirectory named \TEXT, you can change its name to \GRAPH
  271. by entering:
  272.           NAME "\TEXT" AS "\GRAPH"
  273. This is a neat trick, indeed.
  274.      As for using the RENAME command in a similar manner, that simply 
  275. cannot be done.  Since RENAME is an intrinsic command, you would need
  276. to alter COMMAND.COM to fix the problem, and we advise strongly against 
  277. trying that.
  278.  
  279. -----------------------------------------------------------------
  280.                             Up a Tree
  281.          (PC Magazine Vol 4 No 16 Aug 6, 1985 PC Tutor)
  282.  
  283.      If you are in one subdirectory and want to call a program in 
  284. another part of the tree the PATH option lets you to call a .EXE 
  285. or .BAT program file, but not any associated data or .OVL files needed
  286. by the program.  For example, a PE.EXE program needs PE.PRO and both
  287. are in the EDIT subdirectory, but PATH will only call the former.
  288.      There are three possible solutions to this problem which has 
  289. plagued subdirectory users ever since DOS 2.0 was introduced.
  290.      First, there are a number of public domain programs that extend
  291. PATH command capability to include all file searches.  Thus, as the
  292. program searches for overlay files, it will go to the correct
  293. subdirectory.  Some of these programs may do strange things when you
  294. try to create a file.
  295.      Second, there are more sophisticated commercial programs
  296. available that let you specify certain files that are to be found in
  297. specific subdirectories.  This tends to make your environment list
  298. pretty long, but it works.
  299.      The third approach is to update to DOS 3.1 which contains a 
  300. program called SUBST that lets you section off a piece of your 
  301. subdirectory tree as a drive.  For example, if you enter:
  302.           SUBST A: C: \EDIT
  303. this would make the EDIT subdirectory accessible as drive A:, and 
  304. most programs search at least drive A: for required overlays.  If your
  305. program can handle it, use a different drive designator (say E:) since
  306. otherwise drive A: will become temporarily inaccessible for other use.
  307. In this case, type:
  308.           SUBST E: C: \EDIT
  309.  
  310. -----------------------------------------------------------------
  311.                          Find that Path
  312.              (PC World The Help Screen August 1985)
  313.  
  314.      The PC AT's hard disk presents a stubborn problem.  I would like
  315. to place WordStar v3.3 in a word processing directory (\WP) and develop
  316. six to eight subdirectories for text so that letters and other files
  317. on a given topic may be kept together in a specific subdirectory.
  318. Relying on a PATH command that includes the directory C:\WP, I have
  319. tried to create a series of batch files that would change to the
  320. directory containing the text I seek and then call WordStar.
  321.      My efforts to access a working WordStar from any of the
  322. subdirectories have failed.  After WordStar's copyright screen clears,
  323. instead of the opening menu screen, "@@@@" appears in the upper left
  324. corner of the screen.  Only after copying WS*.* into each subdirectory
  325. can I edit documents.  I'm encountering similar problems with other
  326. software.  Only 1-2-3 works, because it allows designation of a
  327. subdirectory as well as a drive for storing worksheet files.
  328.  
  329.      Editor's Response:  Because you have an AT, I will assume you are
  330. using DOS 3.0.  DOS 3.0 contains a file called VDISK.SYS which is a
  331. device driver used to implement a RAM disk.  First create a small RAM
  332. disk and copy a program's files to it.  Next change the current
  333. directory of the hard disk drive to the one you want to hold your data
  334. files.  Then make the RAM disk the default drive and call the program.
  335. (The commands that perform these steps can be incorporated in a batch
  336. file; in that case, you'd just call the batch file to implement the
  337. instructions.)
  338.      Although many popular programs do not recognize paths, most can
  339. take advantage of a dual disk drive environment.  You can keep the
  340. program's files in the current directory on one drive, usually drive
  341. A:, and your data files in the current directory of another drive.
  342. In this case we've substituted a RAM disk for drive A: and a
  343. subdirectory of the hard disk for drive B:.  Many of these applications
  344. also expect all program files, such as configuration files or overlay
  345. files, to be either in the current directory of the default drive or
  346. in drive A:.  Most, however, will allow you to change the drive that
  347. the application assumes is holding its program files.
  348.      WordStar is one such program, which is why it would not run until
  349. its overlay files had been copied into the current subdirectory.  To
  350. get WS.COM to look to the RAM disk for its overlays, use WordStar's
  351. WINSTALL program to change the system disk drive (choice R on
  352. WINSTALL's menu of WordStar features).  If an applications does not
  353. let you choose a drive for its program files, use the command:
  354. ASSIGN A:=d:, substituting the RAM disk drive letter for d.  After
  355. exiting the application, issue the command ASSIGN to clear the prior
  356. assignment and regain the use of drive A:.
  357.      In either case, to change the subdirectories you must exit the
  358. program and, either manually or via a batch file, use the DOS command
  359. CD, then restart the program.
  360.      DOS 3.1 includes a new external command, SUBST, which offers an
  361. easier and more elegant solution for just this problem.  SUBST allows
  362. you to assign a path to a drive specifier in much the same way that
  363. ASSIGN redirects calls for one drive to another.
  364.      A batch file such as the following allows an application to access
  365. subdirectories by referencing the substituted drive letter and, when
  366. the application is exited, to delete the substitutions:
  367.  
  368. SUBST B: C:\WP
  369. SUBST D: C:\WP\LETTERS
  370. SUBST E: C:\WP\MEMO
  371. D:
  372. B:WS %1
  373. SUBST B:/D
  374. SUBST D:/D
  375. SUBST E:/D
  376.  
  377.      You will still need to install WordStar so that it looks to the
  378. proper drive for its overlays (drive B: for his sample substitution),
  379. unless you substitute drive A: for C:\WP.  In addition, to use drive
  380. letters beyond E:, you must reboot with a CONFIG.SYS file that includes
  381. the line LASTDRIVE=d:, where d is the last drive letter used by the
  382. system.
  383.